package me.zk.practice1.sort;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 *
 * 冒泡排序、选择排序、快速排序、
 * @author zhangkai
 * @date 2023/7/29 17:55
 */
public class Sort1 {

    public static void main(String[] args) {
        System.out.println(Arrays.toString(sort(new int[]{2,3,1,9,5,3})));
    }

    //
    public static int[] sort(int[] nums) {

        for (int i = 0; i < nums.length-1; i++) {
            for (int j = 1; j < nums.length-i; j++) {
                if (nums[j] <nums[j-1]) {
                    swap(nums,j,j-1);
                }
            }
        }
        return nums;

    }
    public static void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;

    }

}
